package com.hqyj.javaSpringCloudTest.controller;

import com.hqyj.entity.test.Country;
import com.hqyj.javaSpringCloudTest.service.CountryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description：CountryController
 * @Author ：Cwd
 * @Date ：2021/8/19 15:28
 */
@RestController
@RequestMapping("/api/test/")
public class CountryController {

    @Autowired
    private CountryService countryService;

    /**
     * 127.0.0.1:8761/api/country/522 ---- get
     * @param
     * @return
     */
    @GetMapping("/country/{countryId}")
    public Country getCountryByCountryId(@PathVariable int countryId) {
        return countryService.getCountryByCountryId(countryId);
    }

    /**
     * 127.0.0.1:8761/api/country?countryName=China&localCountryName=Zhongguo ---- get
     * @param countryName
     * @param localCountryName
     * @return
     */
    @GetMapping("/country")     //查询参数 获取
    public Country getCountryByCountryName(@RequestParam String countryName,
                                           @RequestParam String localCountryName) {
        return countryService.getCountryByCountryName(countryName,localCountryName);
    }
}
